Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte-shave and deduplicate infinite query implementation #4804

Conversation

markerikson
Copy link
Collaborator

@markerikson markerikson commented Jan 3, 2025

This PR:

  • Attempts to shrink the bundle size changes of the infinite query PR, by deduplicating places that were intentionally copy-pasted at the start of the PR, and doing other assorted byte-shaving tricks.

Note that some of the byte-shaving is not actually related to this PR, and could be applied to master.

Progress thus far, checking sizes via a Vite React app based off our default template (which has a couple normal query endpoints, but no infinite query endpoints. Note that the size increase is still expected because none of this can tree-shake, so you pay the cost regardless of whether or not you have any infinite queries.

- 2.5.0:              `dist/assets/index-qfEMzmSA.js   217.68 kB │ gzip: 71.25 kB`
- integration:        `dist/assets/index-Bi_rqowG.js   224.67 kB │ gzip: 72.97 kB`
- shaving:      
  - selectors:        `dist/assets/index-DiA9FXmc.js   224.48 kB │ gzip: 72.90 kB`
  - thunks:           `dist/assets/index-BNrKdMuh.js   224.11 kB │ gzip: 72.94 kB`
  - internal:         `dist/assets/index-CWuCWuKB.js   224.03 kB │ gzip: 73.04 kB`
  - selector fix:     `dist/assets/index-ZN5C2aCU.js   224.27 kB │ gzip: 73.01 kB`
  - initiate:         `dist/assets/index-u0d7I2eW.js   223.40 kB │ gzip: 72.75 kB`
  - useSubscription:  `dist/assets/index-DI39JJ7S.js   222.60 kB │ gzip: 72.70 kB`
  - useState:         `dist/assets/index-DtQB8L8Z.js   222.24 kB │ gzip: 72.62 kB`
  - debugValue:       `dist/assets/index-Dd2yXm-V.js   222.01 kB │ gzip: 72.64 kB`
  - hook unsub:       `dist/assets/index-C8CCHuBe.js   221.88 kB │ gzip: 72.64 kB`

Overall, we started with +7K min on the integration branch, and I've shaved off 1.27K min of that. I think I can knock off a few hundred bytes more working on the query hooks.

Sonda visualizations

2.5.0:

image

Integration:

image

Through initiate deduplication:

image

With hooks deduplicated:

image

Copy link

codesandbox bot commented Jan 3, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@markerikson markerikson force-pushed the feature/infinite-query-bundle-size branch from 337e06f to f7754b2 Compare January 3, 2025 23:08
Copy link

codesandbox-ci bot commented Jan 3, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f93bec9:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@markerikson markerikson force-pushed the feature/infinite-query-bundle-size branch from 60668fb to eb56619 Compare January 3, 2025 23:34
Copy link

github-actions bot commented Jan 4, 2025

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit/query/react (modern.mjs) 14.41 KB (-0.44% 🔽)
1. entry point: @reduxjs/toolkit/query (cjs, production.min.cjs) 23.22 KB (-0.44% 🔽)
1. entry point: @reduxjs/toolkit/query/react (cjs, production.min.cjs) 25.63 KB (-0.41% 🔽)
2. entry point: @reduxjs/toolkit/query (without dependencies) (cjs, production.min.cjs) 10.04 KB (-0.72% 🔽)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (cjs, production.min.cjs) 3.08 KB (-1.51% 🔽)
3. createApi (.modern.mjs) 14.82 KB (-0.43% 🔽)
3. createApi (react) (.modern.mjs) 16.84 KB (-0.92% 🔽)

@markerikson markerikson force-pushed the feature/infinite-query-bundle-size branch from 85d9820 to 249e0ec Compare January 5, 2025 21:57
@markerikson markerikson changed the title [DRAFT] Byte-shave and deduplicate infinite query implementation Byte-shave and deduplicate infinite query implementation Jan 5, 2025
@markerikson markerikson merged commit 968db05 into feature/infinite-query-integration Jan 5, 2025
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant